import java.sql.*;
import java.util.Scanner;

public class JDBCDemoPrestament {

    public static final String URL = "jdbc:mysql://localhost:3306/hospital?serverTimezone=GMT-8&useUnicode=true&characterEncoding=utf-8";

    public static final String UserName ="root";

    public static final String PassWord = "12345678";

    public static void TestPreparedStatement(){
        try(Connection conn= DriverManager.getConnection(URL,UserName, PassWord)) {

            System.out.println(conn);
            System.out.println("连接成功");
            //获得命令对象
            PreparedStatement statement=conn.prepareStatement("insert into patient(patientID,password,birthDate,gender,patientName,phoneNum,email,identityNum,address) values(?,?,?,?,?,?,?,?,?) ");


            statement.setInt(1,59);
            statement.setInt(2,666666);
            statement.setString(3,"2001-01-01");
            statement.setString(4,"男");
            statement.setString(5,"黄思成");
            statement.setString(6,"12139");
            statement.setString(7,"12139.com");
            statement.setString(8,"422825200101011111");
            statement.setString(9,"恩施");

            int rows=statement.executeUpdate();
            if (rows>0){
                System.out.println("插入成功");
            }

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        TestPreparedStatement();
    }
}
//
//Scanner scanner4 = new Scanner(System.in);
//        System.out.println("请输入要修改账号的id：");
//int id= scanner4.nextInt();
//        System.out.println("请输入修改后的username:");
//String username4 =scanner4.nextLine();
//        System.out.println("请输入修改后的password:");
//String password4 =scanner4.nextLine();
//TestConnection4(username4,password4,id);